﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ItemOnWorld : MonoBehaviour
{ 
  public Item thisItem;
    public BagSaveGoods PlayerInventory;
  private void OnTriggerEnter2D(Collider2D other)
        {
        if (other.gameObject.CompareTag("Player"))
            {
            AddNewItem();
            Destroy(gameObject);
        }
    }

    public void  AddNewItem()
        {
        if(!PlayerInventory.itemList.Contains(thisItem))
            {
            PlayerInventory.itemList.Add(thisItem);
          
        }
        else
            {
        thisItem.itemHeld+=1;
        }
        InventoryManage.RefreshItem();
    }

  
}
